package com.yoomiito.app.present.my.activity;


import com.yoomiito.app.Constant;
import com.yoomiito.app.base.AppConfig;
import com.yoomiito.app.base.BaseActPresenter;
import com.yoomiito.app.model.bean.IncomeBean;
import com.yoomiito.app.model.my.MyCollectGoodsBean;
import com.yoomiito.app.model.my.MyIncomeBean;
import com.yoomiito.app.net.YmApi;
import com.yoomiito.app.ui.my.MyIncomeActivity;
import com.yoomiito.app.ui.my.MyMonthOrderActivity;
import com.yoomiito.app.utils.NetworkUtils;

import cn.droidlover.xdroidmvp.net.ApiException;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.XApi;

public class MyIncomerPresenter extends BaseActPresenter<MyIncomeActivity> {

    public MyIncomerPresenter(AppConfig appConfig) {
        super(appConfig);
    }


    public void getAccountList(){
        YmApi.getYmService()
                .getAccountList()
                .compose(getV().bindToLifecycle())
                .compose(XApi.<IncomeBean>getApiTransformerData())
                .compose(XApi.<IncomeBean>getScheduler())
                .subscribe(new ApiSubscriber<IncomeBean>(handleException()) {
                    @Override
                    public void onSuccess(IncomeBean data) {
                        getV().setData(data);
                    }

                    @Override
                    public void onFail(ApiException error) {
                        getV().showLoading();
                    }
                });
    }

    public void getHistoryList(int page,int type){
        YmApi.getYmService()
                .getHistoryList(page,type)
                .compose(getV().bindToLifecycle())
                .compose(XApi.<MyIncomeBean>getApiTransformerData())
                .compose(XApi.<MyIncomeBean>getScheduler())
                .subscribe(new ApiSubscriber<MyIncomeBean>(handleException()) {
                    @Override
                    public void onSuccess(MyIncomeBean data) {
                        getV().setData1(data.data);
                    }

                    @Override
                    public void onFail(ApiException error) {
                        getV().showLoading();
                    }
                });
    }

    public void getAgentRebate(int page,String month){
        YmApi.getYmService()
                .getAgentRebate(page,month)
                .compose(getV().bindToLifecycle())
                .compose(XApi.<MyIncomeBean>getApiTransformerData())
                .compose(XApi.<MyIncomeBean>getScheduler())
                .subscribe(new ApiSubscriber<MyIncomeBean>(handleException()) {
                    @Override
                    public void onSuccess(MyIncomeBean data) {
                        getV().setData1(data.data);
                    }

                    @Override
                    public void onFail(ApiException error) {
                        getV().showLoading();
                    }
                });
    }
}
